/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2018-10-30 00:09:03
 * @Description: 左下-攻击地址TOP10
 */
define(function (require) {
  /**
   *  引入tpl模版
   */
  var leftBottomTpl = require('../templates/leftBottom.tpl');

  var LeftBottom = {
    render: function (data) {
      var leftBottomHtml = Handlebars.compile(leftBottomTpl);
      data.sort((a, b) => b.value - a.value);
      var max = parseInt(data[0].value, 10);

      data.forEach(d => {
        d.width = parseInt(d.value * 100 / max, 10)
      })
      $(".left-bottom .top-list").html(leftBottomHtml(data))
      setTimeout(() => {
        $(".left-bottom .top-list").removeClass('active')
      }, 500);
    }
  }
  return LeftBottom
})